<template>
  <div class="posttable">
    <el-row>
      <el-col style="padding-right: 30px;padding-left: 60px;">
        <div class="addform addForm">
          <el-form :label-position="labelPosition" ref="form" :model="form" :rules="rules">
            <el-row class="change">
              <el-col :span="6">
                <el-form-item label="推送客户" prop="customerName" style="margin-bottom: 10px;">
                  <el-select v-model.trim="form.customerName" placeholder="请选择推送客户" @change="selectcustomer">
                    <el-option
                      v-for="item in customerNames"
                      :key="item.id"
                      :label="item.name"
                      :value="item.name">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="需求编号" prop="requireNum" style="margin-bottom: 10px;">
                  <el-select v-model.trim="form.requireNum" placeholder="请选择需求编号" @change="selposition">
                    <el-option
                      v-for="item in num"
                      :key="item"
                      :label="item"
                      :value="item">
                    </el-option>
                  </el-select>
                  <div class="el-form-item__error" v-if="requireNumout">该需求已关闭，请重新选择需求编号!</div>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="!gjsshow">
                <el-form-item label="推送职位" prop="postName" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.postName" placeholder="请选择推送职位" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="gjsshow">
                <el-form-item label="需求名称" prop="postName" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.postName" placeholder="请选择需求名称" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="职位级别" prop="postLevel" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.postLevel" placeholder="请选择职位级别" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="所属区域" prop="area" style="margin-bottom: 10px;">
                  <el-select v-model.trim="form.area" placeholder="请选择所属区域">
                    <el-option
                      v-for="item in Areas"
                      :key="item"
                      :label="item"
                      :value="item">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="性别" prop="sex" style="margin-bottom: 10px;">
                  <el-select v-model.trim="form.sex" placeholder="请选择性别">
                    <el-option
                      label="男"
                      value="男"
                    >
                    </el-option>
                    <el-option
                      label="女"
                      value="女"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="姓名" prop="name" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.name" placeholder="请输入姓名"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="出生年月" prop="birthday" style="margin-bottom: 10px;">
                  <el-date-picker
                    v-model.trim="form.birthday"
                    format="yyyy-MM"
                    value-format="yyyy-MM"
                    type="month"
                    style="width: 274px;"
                    placeholder="请选择出生年月">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="学历" prop="education" style="margin-bottom: 10px;">
                  <el-select v-model.trim="form.education" education placeholder="请选择学历">
                    <el-option
                      v-for="item in education"
                      :key="item.value"
                      :label="item.value"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="毕业院校" prop="college" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.college" placeholder="请输入毕业院校"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="专业" prop="speciality" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.speciality" placeholder="请输入专业"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="毕业时间" prop="graduationTime" style="margin-bottom: 10px;">
                  <el-date-picker
                    v-model.trim="form.graduationTime"
                    format="yyyy-MM"
                    type="month"
                    style="width: 274px;"
                    value-format="yyyy-MM"
                    placeholder="请选择毕业时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="联系方式" prop="phone" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.phone" placeholder="请输入联系方式"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item
                  label="联系邮箱"
                  prop="mail"
                  style="margin-bottom: 10px;"
                >
                  <el-input v-model.trim="form.mail" placeholder="请输入联系邮箱"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="离职状态" prop="status" style="margin-bottom: 10px;">
                  <el-select v-model.trim="form.status" placeholder="请选择离职状态">
                    <el-option
                      v-for="item in status"
                      :key="item.value"
                      :label="item.value"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="到岗时间" prop="entryTime" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.entryTime" placeholder="请输入到岗时间"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="当前薪资(单位(K))" prop="currentSalary" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.currentSalary" placeholder="请输入当前薪资"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="!gjsshow">
                <el-form-item label="期望薪资(单位(K))" prop="expectSalary" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.expectSalary" placeholder="请输入期望薪资" @blur="isSuitSalary"></el-input>
                  <div v-if="Salaryflag" class="el-form-item__error">
                    期望薪资超过薪资上限
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="gjsshow">
                <el-form-item label="rate cate" prop="ratecode" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.ratecode" placeholder="请输入rate cate"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="!gjsshow">
                <el-form-item label="期望薪数" prop="expectSalaryNum" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.expectSalaryNum" placeholder="请输入期望薪数"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="最低薪资(单位(K))" prop="miniSalary" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.miniSalary" placeholder="请输入最低薪资"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-col style="width: 200px;">
                  <el-form-item label="方便面试时间" prop="interviewTime" style="margin-bottom: 10px;">
                    <el-col  class="interviewTime">
                      <el-date-picker
                        width="137px"
                        v-model="form.interviewTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        format="yyyy-MM-dd"
                        placeholder="请输入方便面试时间">
                      </el-date-picker>
                    </el-col>
                  </el-form-item>
                </el-col>
                <el-col style="width: 74px;" class="interviewTime">
                  <el-form-item label="时间范围" style="margin-bottom: 10px;">
                    <el-select v-model.trim="time" placeholder="请选择时间范围" width="137px">
                      <el-option
                        v-for="(item,index) in timelist"
                        :key="index"
                        :label="item"
                        :value="item">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-col>
              <el-col :span="6">
                <el-form-item label="工作年限" prop="workSeniority" style="margin-bottom: 10px;">
                  <el-input v-model.trim="form.workSeniority" placeholder="请输入工作年限"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="简历来源" prop="origin" style="margin-bottom: 10px;">
                  <el-select v-model.trim="form.origin" placeholder="请选择简历来源">
                    <el-option
                      v-for="item in originlist"
                      :key="item.value"
                      :label="item.value"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="学历可查询网站" prop="studentStatus" style="margin-bottom: 10px;">
                  <el-select v-model.trim="form.studentStatus" placeholder="请选择网站">
                    <el-option
                      v-for="(item,index) in websitelist"
                      :key="index"
                      :label="item"
                      :value="item">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>

              <el-col>
                <el-col :span="6">
                  <el-form-item label="资质证书" style="margin-bottom: 10px;">
                    <el-select
                      v-model.trim="form.certificates"
                      placeholder="请输入或者选择资质证书"
                      multiple
                      filterable
                      allow-create
                      @change="selcertificate"
                    >
                      <el-option
                        v-for="(item,index) in certificatelist"
                        :key="index"
                        :label="item"
                        :value="item"
                      >
                      </el-option>
                    </el-select>
                    <!--                    <el-input v-model.trim="form.certificate" placeholder="请输入资质证书"></el-input>-->
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-show="!gjsshow">
                  <el-form-item label="备注" prop="remark" style="margin-bottom: 10px;" class='remark'>
                    <el-input v-model.trim="form.remark" placeholder="请输入备注" style="width: 100%;"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-show="gjsshow">
                  <el-form-item label="语言能力" prop="remark" style="margin-bottom: 10px;" class='remark'>
                    <el-input v-model.trim="form.remark" placeholder="请输入语言能力" style="width: 100%;"></el-input>
                  </el-form-item>
                </el-col>
              </el-col>
              <el-col>
                <el-col :span="12">
                  <el-form-item label="项目经验" prop="experience" style="margin-bottom: 10px;">
                    <el-input style="width: 100%;" type="textarea" v-model.trim="form.experience"
                              placeholder="请输入项目经验"
                              :autosize="{ minRows: 4}"></el-input>
                  </el-form-item>
                </el-col>
              </el-col>

              <el-col :span="12">
                <el-form-item label="初步评价" prop="initialEvaluation" style="margin-bottom: 10px;">
                  <el-input style="width: 100%;" type="textarea" v-model.trim="form.initialEvaluation"
                            placeholder="请输入初步评价"
                            :autosize="{ minRows: 4}"></el-input>
                </el-form-item>
              </el-col>

              <el-col>
                <el-col>
                  <el-form-item style="margin-bottom: 10px;">
                    <div style="max-width:32rem;margin-top: 10px;">
                      <el-upload
                        class="upload-demo"
                        ref="upload"
                        type="file"
                        :action="actionurl"
                        :before-upload="beforeupload"
                        :show-file-list="true"
                        :file-list="fileList"
                        :on-success="handleAvatarSuccess"
                        :on-remove="handleRemove"
                        :limit="2"
                        accept=".pdf,.docx,.doc"
                      >
                        <el-button class="upload" slot="trigger">选取中文文件</el-button>
                        <!--                      :on-change="handleChange"-->
                      </el-upload>
                    </div>
                  </el-form-item>
                  <el-col style="margin-bottom: 30px;">
                    <div v-if="!filetype"
                         style="color: #F56C6C;color: #F56C6C;font-size: 12px;line-height: 1;padding-top: 4px;">
                      文件上传格式为pdf、docx、doc。
                    </div>
                    <div v-if="selectfile"
                         style="color: #F56C6C;color: #F56C6C;font-size: 12px;line-height: 1;padding-top: 4px;">请上传中文文件!
                    </div>
                  </el-col>
                </el-col>
                <el-col v-if="gjsshow">
                  <el-form-item style="margin-bottom: 10px;">
                    <div style="max-width:32rem;margin-top: 10px;">
                      <el-upload
                        class="upload-demo"
                        ref="upload1"
                        type="file"
                        :action="actionurl"
                        :before-upload="beforeupload1"
                        :show-file-list="true"
                        :file-list="fileList1"
                        :on-success="handleAvatarSuccess1"
                        :on-remove="handleRemove1"
                        :limit="2"
                        accept=".pdf,.docx,.doc"
                      >
                        <el-button class="upload" slot="trigger">选取英文文件</el-button>
                        <!--                      :on-change="handleChange"-->
                      </el-upload>
                    </div>
                  </el-form-item>
                  <el-col style="margin-bottom: 30px;">
                    <div v-if="!filetype1"
                         style="color: #F56C6C;color: #F56C6C;font-size: 12px;line-height: 1;padding-top: 4px;">
                      文件上传格式为pdf、docx、doc。
                    </div>
                  </el-col>
                </el-col>
              </el-col>
              <el-col>
                <el-form-item>
                  <el-button class="storage" :disabled="savedis" @click="storageForm()">暂存</el-button>
                  <el-button class="save" :disabled="senddis" @click="submitForm('form')">提交</el-button>
                  <el-button class="canceL" @click="cancel('form')">取消</el-button>
                </el-form-item>
              </el-col>

            </el-row>
          </el-form>
        </div>
      </el-col>
    </el-row>

    <el-dialog
      title="错误"
      :visible.sync="errordialogVisible"
      width="30%"
      :before-close="errorinfoClose"
      class="deletedialog"
    >
      <div style="text-align: center">
        <i class="el-icon-warning" style="font-size: 20px;color: #fcb543;"><span
          style="font-size: 16px;color: #333;margin-left: 12px;">{{errorinfo}}!</span></i>
      </div>
      <span slot="footer" class="dialog-footer">
           <el-button class="sure" round @click="errorinfoClose">确 定</el-button>
    <el-button round @click="errorinfoClose" class="cancel">取 消</el-button>
  </span>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible" :before-close="cancelSend" class="back1">
      <div class="dialogBox">
        <el-row style="border: 1px solid #ccc;">
          <el-col style="padding-left: 10px;" class="resumepushtable">
            <el-table
              class="tablelist"
              ref="mailtable"
              :data="historydata"
              border
            >
              <el-table-column
                prop="customerName"
                label="推送客户"
              >
              </el-table-column>
              <el-table-column
                prop="requireNum"
                label="需求编号"
              >
              </el-table-column>
              <el-table-column
                prop="name"
                label="姓名"
              >
              </el-table-column>
              <el-table-column
                prop="createTime"
                label="推送时间"
              >
                <template slot-scope="scope">
                  <span>{{scope.row.createTime | converTime("YYYY-MM-DD") }}</span>
                </template>
              </el-table-column>
            </el-table>
            <div class="pager">

              <el-pagination
                @size-change="handleSizeChange"
                @current-change="pagehandleCurrentChange"
                :current-page="currentPage"
                :page-sizes="[5,10,15]"
                :page-size="pagesize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="totalcount"
              >
              </el-pagination>
            </div>
          </el-col>

        </el-row>

      </div>
      <div slot="footer" class="dialog-footer">
        <el-row type="flex" justify="center">
          <el-col :span="12">
            <el-col :span="10">
              <el-button type="primary" style="font-size:16px;" :disabled="disabled" @click="sendclick">确 定</el-button>
            </el-col>
            <el-col :span="10">
              <el-button @click="cancelSend">取 消</el-button>
            </el-col>
          </el-col>
        </el-row>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible1" :before-close="cancelSend1" class="back1">
      <div class="dialogBox">
        <el-row style="border: 1px solid #ccc;">
          <el-col style="padding-left: 10px;" class="resumepushtable">
            <el-table
              class="tablelist"
              ref="mailtable"
              :data="historydata1"
              border
            >
              <el-table-column
                prop="customerName"
                label="推送客户"
              >
              </el-table-column>
              <el-table-column
                prop="requireNum"
                label="需求编号"
              >
              </el-table-column>
              <el-table-column
                prop="name"
                label="姓名"
              >
              </el-table-column>
              <el-table-column
                prop="createTime"
                label="推送时间"
              >
                <template slot-scope="scope">
                  <span>{{scope.row.createTime | converTime("YYYY-MM-DD") }}</span>
                </template>
              </el-table-column>
            </el-table>
            <div class="pager">

              <el-pagination
                @size-change="handleSizeChange1"
                @current-change="pagehandleCurrentChange1"
                :current-page="currentPage1"
                :page-sizes="[5,10,15]"
                :page-size="pagesize1"
                layout="total, sizes, prev, pager, next, jumper"
                :total="totalcount1"
              >
              </el-pagination>
            </div>
          </el-col>

        </el-row>

      </div>
      <div slot="footer" class="dialog-footer">
        <el-row type="flex" justify="center">
          <el-col :span="12">
            <el-col :span="10">
              <el-button type="primary" style="font-size:16px;" :disabled="disabled1" @click="sendclick1">确 定
              </el-button>
            </el-col>
            <el-col :span="10">
              <el-button @click="cancelSend1">取 消</el-button>
            </el-col>
          </el-col>
        </el-row>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  import axios from 'axios'
  import qs from 'qs'

  export default {
    name: 'uploadresume',
    props: {
      row: {
        type: Object
      }
    },
    data() {
      var checkexpectSalary = (rule, value, callback) => {
        this.Salaryflag = false;
        var re = /^(\d{1,2})+(\.\d{1,2})?-\d{1,2}$/;
        setTimeout(() => {
          if (value) {
            if (!re.test(value)) {
              callback(new Error('期望薪资的格式为xx-xx且不得超过99'));
            } else {
              //字符串类型的数字类型进行比较时，如果是多位数的数字只会对第一位的数字进行比较，所以需要转换成number类型再进行比较
              var data = Number(value.split('-')[0]);
              var data1 = Number(value.split('-')[1]);
              if (data > data1) {
                callback(new Error('后面的数字必须大于前面的数字'));
              } else {
                callback();
              }
            }
          } else {
            callback()
          }
        }, 100);
      };
      return {
        labelPosition: "top",
        resumeUrl: "",
        resumeName: "",
        form: {
          customerName: '',
          postName: '',
          postLevel: '',
          requireNum: '',
          sex: '男',
          name: '',
          education: '',
          college: '',
          speciality: '',
          graduationTime: '',
          birthday: '',
          area: '',
          phone: '',
          mail: '',
          status: '',
          entryTime: '',
          currentSalary: '',
          expectSalary: '',
          expectSalaryNum: '',
          miniSalary: '',
          interviewTime: '',
          remark: '',
          initialEvaluation: '',
          origin: '',
          studentStatus: '',
          certificates: [],
          experience: '',
          workSeniority: '',
          esId: "",
          fileAddress: '',
          originalFilename: '',
          group: "",
          suffix: "",
          ratecode: '',
          fileNameEn: '',
          fileAddrEn: '',
        },
        gjsshow: false,
        Salaryflag: false,
        requireNumout: false,
        customerNames: [],
        num: [],
        education: [
          {
            value: '大专'
          }, {
            value: '本科'
          }, {
            value: '硕士'
          }, {
            value: '博士'
          }
        ],
        Areas: [],
        status: [
          {
            value: '在职'
          }, {
            value: '离职'
          }
        ],
        originlist: [
          {
            value: '智联'
          }, {
            value: '前程无忧'
          }, {
            value: '猎聘'
          }, {
            value: 'boss'
          }, {
            value: '中华英才'
          }, {
            value: '拉钩'
          }, {
            value: '其他'
          },

        ],
        websitelist: ["学信网", "民信网", "民教网"],
        certificatelist: [],
        customerId: '',
        rules: {
          customerName: [
            {required: true, message: '请选择推送客户', trigger: 'change'}
          ],
          postName: [
            {required: true, message: '请选择推送职位', trigger: 'change'}
          ],
          postLevel: [
            {required: true, message: '请选择职位级别', trigger: 'change'}
          ],
          requireNum: [
            {required: true, message: '请选择需求编号', trigger: 'change'}
          ],
          sex: [
            {required: true, message: '请选择性别', trigger: 'change'}
          ],
          name: [
            {required: true, message: '请输入姓名', trigger: 'blur'}
          ],
          birthday: [
            {required: true, message: '请选择出生年月', trigger: 'change'}
          ],
          education: [
            {required: true, message: '请选择学历', trigger: 'change'}
          ],
          college: [
            {required: true, message: '请输入毕业院校', trigger: 'blur'}
          ],
          speciality: [
            {required: true, message: '请输入专业', trigger: 'blur'}
          ],
          graduationTime: [
            {required: true, message: '请选择毕业时间', trigger: 'change'}
          ],
          area: [
            {required: true, message: '请选择所属区域', trigger: 'change'}
          ],
          phone: [
            {required: true, message: '请输入联系方式', trigger: 'blur'},
            {
              pattern: /(^0\d{2,4}\-\d{7,8}$)|(^1[3|4|5|6|7|8|9][0-9]{9}$)/, message: '请输入正确的联系方式', trigger: 'blur'
            }
          ],
          mail: [
            {required: true, message: '请输入邮箱', trigger: 'blur'},
            {
              pattern: /^[A-Za-z\d]+(([-_.]*)+[A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/,
              message: '请输入正确的邮箱',
              trigger: 'blur'
            }
          ],
          status: [
            {required: true, message: '请选择离职状态', trigger: 'change'}
          ],
          entryTime: [
            {required: true, message: '请输入到岗时间', trigger: 'blur'}
          ],
          currentSalary: [
            {pattern: /^\d{1,2}$/, message: '当前薪资为0-99的数字', trigger: 'blur'}
          ],
          expectSalary: [
            {required: true, message: '请输入期望薪资', trigger: 'blur'},
            {validator: checkexpectSalary, trigger: 'blur'}
          ],
          expectSalaryNum: [
            {required: true, message: '请输入期望薪数', trigger: 'blur'},
            {pattern: /^\d{1,2}$/, message: '期望薪数为0-99的数字', trigger: 'blur'}
          ],
          miniSalary: [
            {pattern: /^\d{1,2}$/, message: '最低薪资为0-99的数字', trigger: 'blur'}
          ],
          origin: [
            {required: true, message: '请选择简历来源', trigger: 'change'}
          ],
          studentStatus: [
            {required: true, message: '请选择网站', trigger: 'change'}
          ],
          experience: [
            {required: true, message: '请输入项目经验', trigger: 'blur'}
          ],
          workSeniority: [
            {required: true, message: '请输入工作年限', trigger: 'blur'},
            {
              pattern: /^[\u4e00-\u9fa5_a-zA-Z0-9_]{0,6}$/, message: '工作年限的长度范围为0-6', trigger: 'blur'
            }
          ],
          initialEvaluation: [
            {required: true, message: '请填写初步评价', trigger: 'blur'}
          ],
          ratecode: [
            {required: true, message: '请输入rate cate', trigger: 'blur'}
          ],
          interviewTime: [
            {required: true, message: '请选择方便面试时间', trigger: 'change'}
          ],
        },
        actionurl: null,
        fileList: [],
        file: {},
        filetype: true,
        selectfile: false,
        fileList1: [],
        file1: {},
        filetype1: true,

        savedis: false,
        senddis: false,
        errordialogVisible: false,
        errorinfo: null,
        disabled: false,
        dialogFormVisible: false,
        historydata: [],
        currentPage: 1,
        pagesize: 5,
        totalcount: null,
        disabled1: false,
        dialogFormVisible1: false,
        historydata1: [],
        currentPage1: 1,
        pagesize1: 5,
        totalcount1: null,
        time : '整天',
        timelist : ["上午","下午","整天"]
      }
    },
    created() {
      this.actionurl = this.url + '/statistics/entryInfo/upload';
      axios.post(this.url + '/resumeUpload/getCustomerNames').then(res => {
        this.unlogin(res.data.code)
        if (res.data.code == 200) {
          this.customerNames = res.data.data;
        }
      });
      axios.get(this.url + "/demand/getAreas").then(res => {
        this.unlogin(res.data.code);
        if (res.data.code == 200) {
          this.Areas = res.data.data;
        }
      });

      this.form.sex = this.row.sex;
      this.form.college = this.row.school;
      this.form.education = this.row.education;
      this.form.speciality = this.row.major;
      this.form.name = this.row.name;
      this.form.phone = this.row.tel.replace(/\s*/g, "");
      this.form.origin = this.row.type;
      this.form.mail = this.row.email.replace(/\s*/g, "");
      this.form.experience = this.row.projectExperience;
      this.form.graduationTime = this.row.graduationTime.match(/\d{4}-\d{2}/).join('');
      this.form.esId = this.row.esId;
    },
    methods: {
      //获取需求编号的下拉框数据
      selectcustomer() {
        this.form.postName = '';
        this.form.requireNum = '';
        this.form.postLevel = '';
        this.form.ratecode = '';
        this.form.fileAddrEn = '';
        this.form.fileAddress = '';
        this.file1 = {};
        this.fileList1 = [];
        this.filetype1 = true;
        if (this.form.customerName == '港交所') {
          this.gjsshow = true;
          this.form.expectSalary = '';
          this.form.expectSalaryNum = '';
          this.form.remark = '';
        } else {
          this.gjsshow = false;
        }

        axios.post(this.url + '/resumeUpload/getNoByCustomerName', qs.stringify({
          customerName: this.form.customerName
        })).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.num = res.data.data
          }
        });
      },
      //获取职位名称和职位级别
      selposition() {
        this.form.postLevel = '';
        this.form.postName = '';
        this.requireNumout = false;

        if (this.form.customerName == "港交所") {
          axios.post(this.url + '/resumeUpload/getDemandNameByCustomerId', qs.stringify({
            no: this.form.requireNum
          })).then(res => {
            this.unlogin(res.data.code)
            if (res.data.code == 200) {
              this.form.postName = res.data.data;
            }
          });
        } else {
          axios.post(this.url + '/resumeUpload/getPostNameByCustomerId', qs.stringify({
            no: this.form.requireNum
          })).then(res => {
            this.unlogin(res.data.code)
            if (res.data.code == 200) {
              this.form.postName = res.data.data;
            }
          });
        }

        axios.post(this.url + '/resumeUpload/getPostLevelByNameAndCustomerId', qs.stringify({
          no: this.form.requireNum
        })).then(res => {
          this.unlogin(res.data.code)
          if (res.data.code == 200) {
            this.form.postLevel = res.data.data;
          }
        })
      },
      clearData() {
        this.requireNumout = false;
        this.errorinfo = null;
      },
      storageForm() {
        this.form.resumeStatus = 'CG';
        this.savedis = true;
        this.form.interviewTime =  this.form.interviewTime  + '/' +  this.time;
        axios.post(this.url + '/resumeUpload/getHistoryUpload', {
          name: this.form.name,
          phone: this.form.phone,
          pageNum: this.currentPage,
          pageSize: this.pagesize
        }).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            if (res.data.data.list.length == 0) {
              this.sendclick();
            } else {
              this.historydata = res.data.data.list;
              this.totalcount = res.data.data.total;
              this.dialogFormVisible = true;
              document.documentElement.style.overflow = 'hidden';
              this.savedis = false;
            }
          }
        })
      },
      submitForm(formName) {
        if (this.file.name == undefined) {
          this.selectfile = true;
        } else {
          this.selectfile = false;
        }
        this.isSuitSalary();
        this.form.interviewTime =  this.form.interviewTime  + '/' +  this.time;
        this.$refs[formName].validate((valid) => {
          if (valid && !this.selectfile  && this.filetype  && this.filetype1 && !this.Salaryflag) {
            this.senddis = true;
            this.form.resumeStatus = 'TJ'
            axios.post(this.url + '/resumeUpload/getHistoryUpload', {
              name: this.form.name,
              phone: this.form.phone,
              pageNum: this.currentPage1,
              pageSize: this.pagesize1
            }).then(res => {
              this.unlogin(res.data.code);
              if (res.data.code == 200) {
                if (res.data.data.list.length == 0) {
                  this.sendclick1();
                } else {
                  this.historydata1 = res.data.data.list;
                  this.totalcount1 = res.data.data.total;
                  this.dialogFormVisible1 = true;
                  document.documentElement.style.overflow = 'hidden';
                  this.senddis = false;
                }
              }
            })
          }
        })
      },
      errorinfoClose() {
        this.errorinfo = null;
        document.documentElement.style.overflow = 'auto';
        this.errordialogVisible = false;
      },
      initdata() {
        this.senddis = false;
        this.savedis = false;
        this.historydata = [];
        this.historydata1 = [];
        this.currentPage = 1;
        this.currentPage1 = 1;
        this.disabled = false;
        this.disabled1 = false;
        this.gjsshow = false;
        this.Salaryflag = false;
        this.time = '整天';
        this.form = {
          customerName: '',
          postName: '',
          postLevel: '',
          requireNum: '',
          sex: '男',
          name: '',
          education: '',
          college: '',
          speciality: '',
          graduationTime: '',
          birthday: '',
          area: '',
          phone: '',
          mail: '',
          status: '',
          entryTime: '',
          currentSalary: '',
          expectSalary: '',
          expectSalaryNum: '',
          miniSalary: '',
          interviewTime: '',
          remark: '',
          initialEvaluation: '',
          origin: '',
          studentStatus: '',
          certificates: [],
          experience: '',
          workSeniority: '',
          esId: "",
          fileAddress: '',
          originalFilename: '',
          group: "",
          suffix: "",
          ratecode: '',
          fileNameEn: '',
          fileAddrEn: '',
        };
        this.num = [];
        this.name = '';
        this.certificatelist = [];
        this.selectfile = false;
        this.filetype = true;
        this.filetype1 = true;
        
        this.file = {};
        this.fileList = [];
        this.file1 = {};
      },
      cancel(formName) {
        this.savedis = false;
        this.senddis = false;
        this.clearData();
        this.$refs[formName].resetFields();
        this.$emit('cancel');
      },
      resetFields(formName) {
        this.$refs[formName].resetFields();
      },
      isSuitSalary() {
        var re = /^(\d{1,2})+(\.\d{1,2})?-\d{1,2}$/;
        if (this.form.expectSalary && this.form.requireNum) {
          if (re.test(this.form.expectSalary)) {
            //字符串类型的数字类型进行比较时，如果是多位数的数字只会对第一位的数字进行比较，所以需要转换成number类型再进行比较
            var data = Number(this.form.expectSalary.split('-')[0]);
            var data1 = Number(this.form.expectSalary.split('-')[1]);
            if (data <= data1) {
              axios.post(this.url + '/resumeUpload/isSuitSalary', {
                no: this.form.requireNum,
                expectSalary: this.form.expectSalary
              }).then(res => {
                this.unlogin(res.data.code);
                if (res.data.code == 200) {
                  if (res.data.data == false) {
                    this.Salaryflag = true
                  } else {
                    this.Salaryflag = false
                  }
                }
              })
            }
          }
        }
        if (this.form.expectSalary == '') {
          this.Salaryflag = false;
        }
      },
      selcertificate() {
        var regu = "^[ ]+$";
        var re = new RegExp(regu);
        for (var i = 0; i < this.form.certificates.length; i++) {
          if (this.certificatelist.indexOf(this.form.certificates[i]) == -1 && !re.test(this.form.certificates[i])) {
            this.certificatelist.push(this.form.certificates[i])
          }
          if (re.test(this.form.certificates[i])) {
            this.form.certificates.splice(i, 1)
          }
        }
      },
      sendclick() {
        this.disabled = true;
        axios.post(this.url + '/screening/addResume',
          this.form).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            if (res.data.message == 'success') {
              this.savedis = false;
              this.disabled = false;
              this.dialogFormVisible = false;
              document.documentElement.style.overflow = 'auto';
              this.clearData();
              this.$emit('cancel');
            } else {
              this.$message({
                message: res.data.message,
                type: 'warning'
              });
            }

            if (res.data.message == '存在该简历信息') {
              this.savedis = false;
              this.dialogFormVisible = false;
              this.disabled = false;
              this.errorinfo = res.data.message;
              document.documentElement.style.overflow = 'hidden';
              this.errordialogVisible = true;
              if(this.form.interviewTime){
                this.form.interviewTime = this.form.interviewTime.split("/")[0];
              }
            }

            if (res.data.message == '该简历不达标不可推送') {
              this.savedis = false;
              this.dialogFormVisible = false;
              this.errorinfo = res.data.message;
              document.documentElement.style.overflow = 'hidden';
              this.errordialogVisible = true;
              this.disabled = false;
              if(this.form.interviewTime){
                this.form.interviewTime = this.form.interviewTime.split("/")[0];
              }
            }
          }
        })
      },
      cancelSend() {
        this.historydata = [];
        this.currentPage = 1;
        this.disabled = false;
        this.dialogFormVisible = false;
        document.documentElement.style.overflow = 'auto';
      },
      beforeupload(file) {
        this.file = {};
        this.file = file;
        this.selectfile = false;
        var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1);
        this.filetype = ((testmsg == 'docx') || (testmsg == 'pdf') || (testmsg == 'doc'));

        if (this.filetype) {
            this.file = file;
            this.fileList = [];
            this.fileList.push(this.file);
        }

        return (this.filetype)
      },
      handleRemove(file, fileList) {
        this.file = {};
        this.fileList = [];
        this.form.originalFilename = '';
        this.form.fileAddress = '';
      },
      handleAvatarSuccess(res, file) {
        this.form.originalFilename = res.data.fileName;
        this.form.fileAddress = res.data.fileAddress;
        this.form.group = res.data.group;
        this.form.suffix = res.data.suffix;
      },
      beforeupload1(file) {
        this.file1 = {};
        this.file1 = file;
        var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1);
        this.filetype1 = ((testmsg == 'docx') || (testmsg == 'pdf') || (testmsg == 'doc'));
        if (this.filetype1) {
            this.file1 = file;
            this.fileList1 = [];
            this.fileList1.push(this.file1);
        }
        return (this.filetype1)
      },
      handleRemove1(file, fileList) {
        this.fileList1 = [];
        this.file = {};
        this.form.fileNameEn = '';
        this.form.fileAddrEn = '';
      },
      handleAvatarSuccess1(res, file) {
        this.form.fileNameEn = res.data.fileName;
        this.form.fileAddrEn = res.data.fileAddress;
      },
      //修改当前表格页数
      pagehandleCurrentChange(val) {
        this.currentPage = val;
        axios.post(this.url + '/resumeUpload/getHistoryUpload', {
          name: this.form.name,
          phone: this.form.phone,
          pageNum: this.currentPage,
          pageSize: this.pagesize
        }).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.historydata = res.data.data.list;
            this.totalcount = res.data.data.total;
          }
        })
      },
      //改变表格的页面展示数量
      handleSizeChange(val) {
        this.pagesize = val;
        axios.post(this.url + '/resumeUpload/getHistoryUpload', {
          name: this.form.name,
          phone: this.form.phone,
          pageNum: this.currentPage,
          pageSize: this.pagesize
        }).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.historydata = res.data.data.list;
            this.totalcount = res.data.data.total;
          }
        })
      },
      sendclick1() {
        this.disabled1 = true;
        axios.post(this.url + '/screening/addResume',
          this.form).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            if (res.data.message == 'success') {
              this.senddis = false;
              this.disabled1 = false;
              this.dialogFormVisible1 = false;
              document.documentElement.style.overflow = 'auto';
              this.clearData();
              this.$emit('cancel')
            }

            if (res.data.message == '存在该简历信息') {
              this.senddis = false;
              this.dialogFormVisible1 = false;
              this.disabled1 = false;
              this.errorinfo = res.data.message;
              document.documentElement.style.overflow = 'hidden';
              this.errordialogVisible = true;
              this.form.interviewTime = this.form.interviewTime.split("/")[0];
            }

            if (res.data.message == '该需求已关闭') {
              this.senddis = false;
              this.requireNumout = true;
              this.disabled1 = false;
              this.dialogFormVisible1 = false;
              this.form.interviewTime = this.form.interviewTime.split("/")[0];
            }

            if (res.data.message == '该简历不达标不可推送') {
              this.senddis = false;
              this.dialogFormVisible = false;
              this.errorinfo = res.data.message;
              document.documentElement.style.overflow = 'hidden';
              this.errordialogVisible = true;
              this.disabled1 = false;
              this.form.interviewTime = this.form.interviewTime.split("/")[0];
            }
          }
        })
      },
      cancelSend1() {
        this.disabled1 = 1;
        this.historydata1 = [];
        this.currentPage1 = 1;
        this.dialogFormVisible1 = false;
        document.documentElement.style.overflow = 'auto';
      },
      //修改当前表格页数
      pagehandleCurrentChange1(val) {
        this.currentPage1 = val;
        axios.post(this.url + '/resumeUpload/getHistoryUpload', {
          name: this.form.name,
          phone: this.form.phone,
          pageNum: this.currentPage1,
          pageSize: this.pagesize1
        }).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.historydata1 = res.data.data.list;
            this.totalcount1 = res.data.data.total;
          }
        })
      },
      //改变表格的页面展示数量
      handleSizeChange1(val) {
        this.pagesize1 = val;
        axios.post(this.url + '/resumeUpload/getHistoryUpload', {
          name: this.form.name,
          phone: this.form.phone,
          pageNum: this.currentPage1,
          pageSize: this.pagesize1
        }).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.historydata1 = res.data.data.list;
            this.totalcount1 = res.data.data.total;
          }
        })
      },
    },
  }
</script>
<style scoped>
  .addform {
    color: #333 !important;
  }

  .storage {
    width: 150px;
    height: 40px;
    font-size: 16px;
    color: #4e72f3;
    border-radius: 4px;
    margin-right: 43px;
    border-color: #4e72f3;
  }

  .save {
    width: 150px;
    height: 40px;
    font-size: 16px;
    color: #fff;
    border-radius: 4px;
    margin-right: 43px;
    background: linear-gradient(to bottom, #5696f8 0%, #4e6ef5 100%);
  }

  .canceL {
    width: 150px;
    height: 40px;
    border: 1px solid #4e6ef5;
    font-size: 16px;
    font-weight: 500;
    color: #4e6ef5;
  }

  .upload {
    width: 194px;
    height: 44px;
    margin-top: 10px;
    /*margin-bottom: 30px;*/
  }

  .pager {
    width: 100%;
    overflow: hidden;
    position: relative;
    margin-top: 10px;
    margin-bottom: 10px;
  }

  .el-pagination {
    margin-left: 50%;
    transform: translateX(-50%);
  }
</style>
